<?php namespace App\Utils\Sms;


class ChuangLanVoiceCodeByV2Version {

    public function sendVoiceCode($phoneNum, $code) {
        // 构造请求数据
        $ACCOUNT_NAME = "YC2113861";  //帐号
        $ACCOUNT_PWD = "x6dDV7ftbZa805"; //密码
        $KEY = "dc3230099de0cba84d573cb8ddd0874a"; //key
        $BASE_URL = "http://audio.253.com/";
        $funAndOperate = "voice?method=vcfplay&voiceinfo=";
        $url =  $BASE_URL . $funAndOperate;

        date_default_timezone_set("Asia/Shanghai");
        $timestamp = date("YmdHis");

        //接口参数
        $data = array();
        $data['organization'] = $ACCOUNT_NAME; //必填
        $data['phonenum'] = $phoneNum; //必填
        $data['timestamp'] = $timestamp; //选填
        $data['content'] = md5($KEY.$data['phonenum'].$ACCOUNT_PWD.$timestamp); //必填
        $data['vfcode'] = $code; //必填
        $data['shownum'] = '95213176';  //审核通过的来电显示号码  //必填

        //以下为选填
        $data['uniqueid'] = uniqid();  //请求唯一标识  //选填
        $data['ringtime'] = 45; //选填
        $data['ivrfileid'] = '141';//选填
        $bodyArr['voiceinfo'] = $data;
        $body = urlencode(json_encode($bodyArr));
        $url = $url.$body;
        // 提交请求
        $con = curl_init();
        curl_setopt($con, CURLOPT_URL, $url);
        curl_setopt($con, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt ($con, CURLOPT_HEADER, 0);
        curl_setopt ($con, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($con, CURLOPT_POST, false);
        $result = curl_exec($con);
        // $httpinfo = curl_getinfo($con);
        curl_close($con);
        return $result;
    }
}
?>